<?php
declare (strict_types=1);

namespace app\controller\home;

use app\common\controller\BaseController;
use app\common\model\Banner as bannerModel;
use think\App;

class Banner extends BaseController
{
    protected $model;

    public function __construct(App $app, bannerModel $model)
    {
        parent::__construct($app);
        $this->model = $model;
    }

    /**
     * 列表查询
     * @return array
     */
    public function query()
    {
        $where = [];
        $where['delete_time'] = 0;
        $where['status'] = 1;
        $page = input('page/d', 1);
        $pageSize = input('page_size/d', 20);
        $type = input('type/d', 1);
        $where['type'] = $type;
        $order = ['sort' => 'DESC'];
        $fields = 'id,image_url,type,sort,create_time';
        return $this->model->getList($where, $fields, $order, $page, $pageSize);
    }
}
